< previous page page_392 next page >

Page 392
   ReDim startaddresses(NameCount - 1)
   ReDim Ordinals(NameCount - 1)
   ReDim Names(NameCount)

   ' Load an array with all the ordinals
   sourceloc = ExportDirectory.AddressOfNameOrdinals - ExportSectionOffset + 1
   Get #FileHandle, sourceloc, Ordinals()
   For idx = 0 To NameCount-1
      Ordinals(idx) = Ordinals(idx) + ExportDirectory.Base
   Next idx

   ' Make a copy of all the start addresses
   sourceloc = ExportDirectory.AddressOfNames - ExportSectionOffset + 1
   Get #FileHandle, sourceloc, startaddresses()

   ' Preload the entire section for speed
   ReDim ExportsBuffer(Sections(ExportSection).SizeOfRawData)
   Get #FileHandle, Sections(ExportSection).PointerToRawData + 1, _
   ExportsBuffer()

   ' Extract each start array
   For idx = 0 To NameCount - 1
      sourceloc = startaddresses(idx)-ExportSectionOffset -
Sections(ExportSection).PointerToRawData
      ' Preinitialize the string
      ' Calculate the length of the string
      'Debug.Print sourceloc
      If sourceloc > 0 Then
         stringlen = lstrlenFromPtr(VarPtr(ExportsBuffer(sourceloc)))
         tempstr = String$(stringlen + 1, 0)
         Call lstrcpyFromPtr(tempstr, VarPtr(ExportsBuffer(sourceloc)))
         Names(idx + 1) = Left$(tempstr, stringlen)
      End If
      'Debug.Print tempstr
   Next idx
End Sub
The function begins by determining the number of exported functions and dimensioning three arrays: one for a temporary address for each function, one for the ordinal value, and one for the function name.

 
< previous page page_392 next page >